﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace BusinessObjects
{
#if Silverlight
    [Serializable]
#else
    [DataContract]
#endif
    public class Game
    {
        private List<Player> players;
        private GameLevelInfo gameLevelinfo;

        [XmlIgnore]
        private List<GameObject> gameObjects;

        [XmlIgnore]
        private List<List<int>> grid;

        public Game()
        {
        }

        [DataMember]
        public int MapId
        {
            get;
            set;
        }

        [DataMember]
        public List<Player> Players
        {
            get
            {
                if ( this.players == null )
                    this.players = new List<Player>();
                return this.players;
            }
            set { this.players = value; }
        }

        [DataMember]
        public List<GameObject> GameObjects
        {
            get
            {
                if ( this.gameObjects == null )
                    this.gameObjects = new List<GameObject>();
                return this.gameObjects;
            }
            set { this.gameObjects = value; }
        }

        [DataMember]
        public GameLevelInfo GameLevelInfo
        {
            get { return this.gameLevelinfo; }
            set { this.gameLevelinfo = value; }
        }

        /// <summary>
        /// Contains all map's regions
        /// </summary>
        [XmlIgnore]
        [DataMember]
        public List<List<int>> Grid
        {
            get
            {
                if ( this.grid == null )
                    this.grid = new List<List<int>>();

                return this.grid;
            }
        }
        
        [XmlIgnore]
        [DataMember]
        public List<string> GridDefinition
        {
            get;
            set;
        }

        [DataMember]
        public List<RegionObjectHolder> SimplifiedGameObjects
        {
            get;
            set;
        }
    }
}
